





<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/touwei.css"> 
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/frameset.css"/>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/globalStyle.css"/>
<script src="http://web.mcooz.com/dogegg_mini/kissy-min.js" charset="utf-8"></script>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/form.css">
<title>订单</title>
<style type="text/css">
    
/* toubu */

.bg1 {
  margin: auto;
  width: 1190px;
}

.kros_warp {
  background: none repeat scroll 0 0 #f8f8f8;
  border-bottom: 1px solid #e7e7e7;
  color: #333;
  height: 25px;
  line-height: 25px;
  width: 100%;
  z-index: 110;
}

.header-top {
   font-size: 12px;
  height: 25px;
  line-height: 25px;
 
}
.header-top {
  background-color: #f8f8f8;
  
}
.kros_warp1{
    width: 100%;
}
.OrangerWrapCenterCententTT{
  text-align: left;
}
.header-top .left a,.header-top .right a{
  color: #555;
}
.header-top .left a:hover,.header-top .right a:hover{
  color: #ff9400;
}

.search div.ui-dropOranger {

  display: table;

}

.mr10 {
  color: #555;
}
.header-center .erweima {
 background-repeat: no-repeat;
}

/* toubu */


</style>
</head>

<body>

<div class="kros_warp" id="fixed">
        <div class="header-top bg1">
                    <div class="left ml10">
                        <a href="">万启控股</a><span>|</span>
                        <a href="">万启万贷</a><span>|</span>
                        <a href="">万启私享</a>
                    </div>
                    <div class="right mr10">
                        <a href="">办公桌</a>
                        {if:$this->user}
            {echo:$this->user['username']}您好，欢迎您来到{echo:$siteConfig->name}购物！[<a href="{url:/simple/logout}" class="reg">安全退出</a>]
            {else:}
                        <a href="{url:/simple/reg?callback=$callback}" style="margin-right:0px;">注册</a>/<a href="{url:/simple/login?callback=$callback}" style="margin-left:0px;">登录</a>
                      {/if}
                        <a href="{url:/simple/cart}">购物车</a>
                        <a href="">帮助中心</a>
                    </div>
                </div>
</div>
<div style="visibility: hidden; margin: 0px; padding: 0px; width: 1903px; height: 0px; float: none;"></div>

 <div id="stick" class="kros_wrap1">
                <div class="header-center bg1">
                    <a href="/" class="logo" style="background-repeat: no-repeat;display:block"></a>
                    <!--<div class="search"><input type="text" name="searchtext" class="searchtext"/><input type="button" value="搜索" class="search"/></div>-->
                    <div class="search">
                        <form method='get' action='{url:/}'>
                            <input type='hidden' name='controller' value='site' />
                            <input type='hidden' name='action' value='search_list' />
                       <!--    <input class="text" type="text" name='word' autocomplete="off" value="输入关键字..." />
                       <input class="btn" type="submit" value="商品搜索" onclick="checkInput('word','输入关键字...');" /> -->
                       
                        <div class="ui-dropOranger">
                            <span class="ui-dropOranger-hd">
                                <span>全部</span>
                                <i class="iconfont icon-font"></i>
                            </span>
                           <!-- <ul class="unstyled ui-dropdown-menu" style="display: none;">
                                <li class="hide" data-type="witkey">
                                    <a href="javascript:;">找服务商</a>
                                </li>
                                <li data-type="task">
                                    <a href="javascript:;">找&nbsp;需&nbsp;求</a>
                                </li>
                                <li data-type="service">
                                    <a href="javascript:;">找&nbsp;服&nbsp;务</a>
                                </li>
                             </ul>-->
                         </div>
                         <input data-type="witkey" name="word" value="" id="j-header-kw" type="text" class="searchtext470" placeholder="输入关键字" autocomplete="off" disableautocomplete="" autocorrect="off" onwebkitspeechchange="this.form.submit();" lang="zh-CN" x-webkit-grammar="builtin:search" x-webkit-speech="true">
                         <button type="submit" class="search60">搜索</button>

                         </form>
                    </div>
                    <div class="erweima"></div>
                </div>
      </div>









	<div class="bg">
    	<div id="globalStyleWrap">
        <div id="headerWrap">
            	
             
            </div>
            <div id="globalStyleWrapCentent">
            	<div class="formCentent">
                	<div class="formUp">
                    	<p>选择服务</p>
                        <div class="formUpAll">
                        	<div class="left formUpAN" >
                            	<input type="button" style="background-image:url({skin:form/formL.png})">
                            </div>
                        	<div class="formAD1"></div>
                            <div class="formAD"></div>
                            <div class="formAD"></div>
                            <div class="formAD"></div>
                            <div class="formAD"></div>
                            <div class="formAD1" style="border-right:none;"></div>
                            <div class="formUpAN right">
                            	<input type="button" style="background-image:url({skin:form/formR.png})">
                            </div>
                        </div>
                    </div>
                    <div class="formLeft">
                        <div class="formTop">
                        	<p>服务介绍</p>
                        </div>
                        <div>
                            <div class="purple950">
                            	<p>办公用品</p>
                                <a href="#"><img src="{skin:form/orderFormxia.png}" class="img"></a>
                            </div>
                            <!--
                            <div class="text950">
                            	<input type="text" value="" class="text300" placeholder="请填写培训课程主题">
                            </div>
                            -->
                        </div>
                        <div>
                            <div class="purple950">
                            	<p>公关赠品</p>
                                <a href="#"><img src="{skin:form/orderFormshang.png}" class="img"></a>
                            </div>
                            <div class="text950">
                            	<div class="checkbox">
                            		<input type="checkbox">贺卡
                                </div>
                                <div class="checkbox">
                                	<input type="checkbox">明信片
                                </div>
                                <div class="checkbox">
                                	<input type="checkbox">专用请柬
                                </div>
                                <div class="checkbox">
                                	<input type="checkbox">邀请函及信封
                                </div>
                                <div class="checkbox">
                                	<input type="checkbox">手提袋
                                </div>
                                <div class="checkbox">
                                	<input type="checkbox">钥匙牌
                                </div>
                                <div class="checkbox">
                                	<input type="checkbox">鼠标垫
                                </div>
                                <div class="checkbox">
                                	<input type="checkbox">礼品盒
                                </div>
                                <div class="checkbox">
                                	<input type="checkbox">台历
                                </div>
                                <div class="checkbox">
                                	<input type="checkbox">包装纸
                                </div>
                                <div class="checkbox">
                                	<input type="checkbox">标识伞
                                </div>
                            </div>
                        </div>
                        <div>
                            <div class="purple950">
                            	<p>员工服饰</p>
                                <a href="#"><img src="{skin:form/orderFormxia.png}" class="img"></a>
                            </div>
                        </div>
                        <div>
                            <div class="purple950">
                            	<p>企业车体外观</p>
                                <a href="#"><img src="{skin:form/orderFormxia.png}" class="img"></a>
                            </div>
                        </div>
                        <div>
                            <div class="purple950">
                            	<p>标志符号指示系统</p>
                                <a href="#"><img src="{skin:form/orderFormxia.png}" class="img"></a>
                            </div>
                        </div>
                        <div>
                            <div class="purple950">
                            	<p>企业广告宣传</p>
                                <a href="#"><img src="{skin:form/orderFormxia.png}" class="img"></a>
                            </div>
                        </div>
                        <div>
                            <div class="purple950">
                            	<p>展览指示系统</p>
                                <a href="#"><img src="{skin:form/orderFormxia.png}" class="img"></a>
                            </div>
                        </div>
                        <div>
                            <div class="purple950">
                            	<p>销售店面标识系统</p>
                                <a href="#"><img src="{skin:form/orderFormxia.png}" class="img"></a>
                            </div>
                        </div>
                        <div>
                            <div class="purple950">
                            	<p>品包装识别系统</p>
                                <a href="#"><img src="{skin:form/orderFormxia.png}" class="img"></a>
                            </div>
                        </div>
                    </div>
                    <div class="fromRight">
                    	<div class="tianjia">
                        	<p>￥999999.999</p>
                            <span>此价格为”老板来啦“标准单位价格，清查爱看详细说明。</span>
                            <input type="submit" class="btPurple210" value="提交需求">
                        </div>
                        <div class="zhaiyao">
                        	<p class="TT left">摘要</p>
                            <div class="centent">
                            	<p><a href="#">&nbsp;&nbsp;&nbsp;贺卡</a></p>
                                <p><a href="#"><img src="{skin:form/de.png}">&nbsp;鼠标垫</a></p>
                            </div>
                        </div>
                    </div>
                </div>
            	 <div class="OrangerWrapCenterCententAD">
                	<!--<P>联合推广区</P>-->
                    
                    <div class="OrangerWrapCenterADCentent">
                    	<div class="centent mt40"></div>
                        <div class="centent"></div>
                        <div class="centent"></div>
                        <div class="centent"></div>
                        <div class="centent"></div>
                        <div class="centent" style="margin-right:0px;"></div>
                        <div class="centent mt10"></div>
                        <div class="centent mt10"></div>
                        <div class="centent mt10"></div>
                        <div class="centent mt10"></div>
                        <div class="centent mt10"></div>
                        <div class="centent mt10" style="margin-right:0px;"></div>
                    </div>
                </div>
            </div>
            <div class="clear"></div>
             <div id="footerWrap">
				<div class="footer-hd">
    				<div class="dl-footer-hd">
                    	<dl>
                        	<dt>标题标题</dt>
                            <dd>内容内容</dd>
                            <dd>内容内容</dd>
                            <dd>内容内容</dd>
                            <dd>内容内容</dd>
                            <dd>内容内容</dd>
                        </dl>
                    </div>
                    <div class="dl-footer-hd">
                    	<dl>
                        	<dt>标题标题</dt>
                            <dd>内容内容</dd>
                            <dd>内容内容</dd>
                            <dd>内容内容</dd>
                            <dd>内容内容</dd>
                            <dd>内容内容</dd>
                        </dl>
                    </div>
                    <div class="dl-footer-hd">
                    	<dl>
                        	<dt>标题标题</dt>
                            <dd>内容内容</dd>
                            <dd>内容内容</dd>
                            <dd>内容内容</dd>
                            <dd>内容内容</dd>
                            <dd>内容内容</dd>
                        </dl>
                    </div>
                    <div class="dl-footer-hd">
                    	<dl>
                        	<dt>标题标题</dt>
                            <dd>内容内容</dd>
                            <dd>内容内容</dd>
                            <dd>内容内容</dd>
                            <dd>内容内容</dd>
                            <dd>内容内容</dd>
                        </dl>
                    </div>
                    <div class="phoneNumer">
                    	<h1>400-890-1117</h1>
                        <p>周一至周五 8:00-18:00</p>
                    </div>
    			</div>
    			<div class="footer-bd">
    				<div class="a-footer-bd">
                    	<a href="#">关于我们</a><span>|</span>
                        <a href="#">合作伙伴</a><span>|</span>
                        <a href="#">联系方式</a><span>|</span>
                        <a href="#">广告服务</a><span>|</span>
                        <a href="#">新闻中心</a><span>|</span>
                        <a href="#">招贤纳士</a><span>|</span>
                        <a href="#">法律声明</a>
                    </div>
                    <div class="yq-footer-bd">
                    	友情链接：
                        <a href="">万启控股</a>
                        <a href="">万启私享</a>
                        <a href="">万启万贷</a>
                        <a href="">大唐财富</a>
                        <a href="">中融信托</a>
                        <a href="">腾讯网</a>
                        <a href="">人民网</a>
                        <a href="">淘宝网</a>                      
                    </div>
                    <div class="ba-footer-bd">
                    	<p>Copyright  2013-2014 京ICP备14029531号-1</p>
                    </div>
    			</div>
			</div>
        </div>
    </div>
    <script type="text/javascript">
var S = KISSY;
  S.use('gallery/sticky/1.1/index', function (S, Sticky) {
    
    var sticky = new Sticky({
               el: '#stick',
            top: 25, 
            target: 'body',
            callback: function(status) { 
               if (status) {
                   S.one('#stick').css({ width: "100%",zIndex:"100",backgroundColor:"#fff",boxShadow:"0 1px 5px #ddd",borderBottom:"1px solid #e6e6e6"}); 
                } else {
                    S.one('#stick').css({ width: "100%",zIndex:"100",backgroundColor:"#fff",boxShadow:"0 0 0 0",borderBottom:"0px solid #e6e6e6"}); 
                }
                            }
        });
Sticky.fixed('#fixed');

});
</script>

<script type="text/javascript">
    //商品加入购物车
function joinCart()
{
    if(!checkSpecSelected())
    {
        tips('请先选择商品的规格');
        return;
    }

    var buyNums   = parseInt($.trim($('#buyNums').val()));

    var price     = parseFloat($.trim($('#real_price').text()));
    
    var productId = $('#product_id').val();
    
    var type      = productId ? 'product' : 'goods';


    var goods_id  = (type == 'product') ? productId : {$id};

    $.getJSON('{url:/simple/joinCart}',{"goods_id":goods_id,"type":type,"goods_num":buyNums,"random":Math.random},function(content){
        if(content.isError == false)
        {
            //获取购物车信息
            $.getJSON('{url:/simple/showCart}',{"random":Math.random},function(json)
            {
                $('[name="mycart_count"]').text(json.count);
                $('[name="mycart_sum"]').text(json.sum);

                //展示购物车清单
                $('#product_myCart').show();

                //暂闭加入购物车按钮
                $('#joinCarButton').attr('disabled','disabled');
            });
        }
        else
        {
            alert(content.message);
        }
    });
}
</script>


<script type="text/javascript">
$(function(){

//图片初始化
var goodsSmallPic = "{skin:images/front/nopic_435_435.gif}";
var goodsBigPic   = "{skin:images/front/nopic_435_435.gif}";

//存在图片数据时候
{if:isset($photo) && $photo}
goodsSmallPic = "{webroot:}{echo:Thumb::get($photo[0]['img'],435,435)}";
goodsBigPic   = "{webroot:}{$photo[0]['img']}";
{/if}

//初始化商品轮换图
var bxObj = $('#thumblist').bxSlider({
    infiniteLoop: false,
    hideControlOnEnd: true,
    pager:false,
    minSlides: 5,
    maxSlides: 5,
    slideWidth: 142,
    slideMargin: 15,
    controls:false,
    onSliderLoad:function(currentIndex){
        //设置图片
        $('#smallPicBox').attr('src',goodsSmallPic);
        $('#bigPicBox').attr('href',goodsBigPic);

        //开启放大镜
        $('.jqzoom').jqzoom({
            title:false,
            lens:true,
            preloadText:'加载中...',
            zoomWidth:400,
            zoomHeight:300,
            xOffset:15,
            zoomType: 'standard',
            preloadImages: false
        });
    }
});

//如果抢购或团购过期则不许立即购买
{if:$promo!='' && !isset($promotion) && !isset($regiment)}
    closeBuy();
{/if}

//如果当前是团购
{if:isset($regiment)}
    {set:$reg_id = IFilter::act(IReq::get('active_id'),'int');}

    //团购检查,1,人数已满 2,已经参加过
    {if:Regiment::isFull($reg_id) || (isset($this->user['user_id']) && Regiment::hasJoined($reg_id,$this->user['user_id'])) || (ICookie::get("regiment_".$reg_id) && Regiment::hasJoined($reg_id,ICookie::get("regiment_".$reg_id)))}
        closeBuy();
    {/if}
{/if}

//开启倒计时功能
var cd_timer = new countdown();

//限时抢购倒计时
{if:isset($promotion)}
cd_timer.add('promotiona');
{/if}

//团购倒计时
{if:isset($regiment)}
cd_timer.add('promotionb');
{/if}

//城市地域选择按钮事件
$('.sel_area').hover(
    function(){
        $('.area_box').show();
    },function(){
        $('.area_box').hide();
    }
);
$('.area_box').hover(
    function(){
        $('.area_box').show();
    },function(){
        $('.area_box').hide();
    }
);

//获取地址的ip地址
getAddress();

//生成商品价格
var priceHtml = template.render('priceTemplate',{"group_price":"{$group_price}","minSellPrice":"{$minSellPrice}","maxSellPrice":"{$maxSellPrice}","sell_price":"{$sell_price}"});
$('#priceLi').replaceWith(priceHtml);

//按钮绑定
$('[name="showButton"]>label').click(function(){
    $(this).siblings().removeClass('current');
    if($(this).hasClass('current') == false)
    {
        $(this).addClass('current');
    }
    $('[name="showBox"]>div').addClass('hidden');
    $('[name="showBox"]>div:eq('+$(this).index()+')').removeClass('hidden');

    switch($(this).index())
    {
        case 1:
        {
            comment_ajax();
        }
        break;

        case 2:
        {
            history_ajax();
        }
        break;

        case 3:
        {
            refer_ajax();
        }
        break;

        case 4:
        {
            discuss_ajax();
        }
        break;
    }
});

});

//禁止购买
function closeBuy()
{
    if($('#buyNowButton').length > 0)
    {
        $('#buyNowButton').attr('disabled','disabled');
        $('#buyNowButton').addClass('disabled');
    }

    if($('#joinCarButton').length > 0)
    {
        $('#joinCarButton').attr('disabled','disabled');
        $('#joinCarButton').addClass('disabled');
    }
}

//开放购买
function openBuy()
{
    if($('#buyNowButton').length > 0)
    {
        $('#buyNowButton').removeAttr('disabled');
        $('#buyNowButton').removeClass('disabled');
    }

    if($('#joinCarButton').length > 0)
    {
        $('#joinCarButton').removeAttr('disabled');
        $('#joinCarButton').removeClass('disabled');
    }
}

//加载根据地域获取城市
function getAddress()
{
    //根据IP查询所在地
    var ipAddress = $.cookie('ipAddress');
    if(ipAddress)
    {
        searchDelivery(ipAddress);
    }
    else
    {
        $.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js',function(){
            ipAddress = remote_ip_info['province'];
            $.cookie('ipAddress',ipAddress);
            searchDelivery(ipAddress);
        });
    }
}

//发表讨论
function sendDiscuss()
{
    var userId = "{$this->user['user_id']}";
    if(userId)
    {
        $('#discussTable').show('normal');
        $('#discussContent').focus();
    }
    else
    {
        alert('请登陆后再发表讨论!');
    }
}

/**
 * 根据省份获取运费信息
 * @param province 省份名称
 */
function searchDelivery(province)
{
    var url = '{url:/block/searchPrivice/random/@random@}';
    url = url.replace("@random@",Math.random);

    $.getJSON(url,{'province':province},function(json)
    {
        if(json.flag == 'success')
        {
            delivery(json.area_id,province);
        }
    });
}

/**
 * 计算运费
 * @param provinceId
 * @param provinceName
 */
function delivery(provinceId,provinceName)
{
    $('.sel_area').text(provinceName);

    var weight  = '{$weight}';
    var buyNums = $('#buyNums').val();

    //通过省份id查询出配送方式，并且传送总重量计算出运费,然后显示配送方式
    var totalWeight = parseInt(weight) * parseInt(buyNums);
    var url = '{url:/block/order_delivery}';

    $.getJSON(url,{'province':provinceId,'total_weight':totalWeight,'random':Math.random},function(json)
    {
        //清空配送信息
        $('#deliveInfo').empty();

        for(var item in json)
        {
            var deliveRowHtml = template.render('deliveInfoTemplate',json[item]);
            $('#deliveInfo').append(deliveRowHtml);
        }
    });
}



/**
 * 获取购买记录数据
 * @page 分页数
 */
function history_ajax(page)
{
    if(!page && $.trim($('#historyBox').text()))
    {
        return;
    }
    page = page ? page : 1;
    var url = '{url:/site/history_ajax/page/@page@/goods_id/$id}';
    url = url.replace("@page@",page);
    $.getJSON(url,function(json)
    {
        //清空购买历史记录
        $('#historyBox').empty();
        $('#historyBox').parent().parent().find('.pages_bar').remove();

        for(var item in json.data)
        {
            var historyHtml = template.render('historyRowTemplate',json.data[item]);
            $('#historyBox').append(historyHtml);
        }
        $('#historyBox').parent().after(json.pageHtml);
    });
}

/**
 * 获取购买记录数据
 * @page 分页数
 */
function refer_ajax(page)
{
    if(!page && $.trim($('#referBox').text()))
    {
        return;
    }
    page = page ? page : 1;
    var url = '{url:/site/refer_ajax/page/@page@/goods_id/$id}';
    url = url.replace("@page@",page);
    $.getJSON(url,function(json)
    {
        //清空评论数据
        $('#referBox').empty();

        for(var item in json.data)
        {
            var commentHtml = template.render('referRowTemplate',json.data[item]);
            $('#referBox').append(commentHtml);
        }
        $('#referBox').append(json.pageHtml);
    });
}

/**
 * 获取购买记录数据
 * @page 分页数
 */
function discuss_ajax(page)
{
    if(!page && $.trim($('#discussBox').text()))
    {
        return;
    }
    page = page ? page : 1;
    var url = '{url:/site/discuss_ajax/page/@page@/goods_id/$id}';
    url = url.replace("@page@",page);
    $.getJSON(url,function(json)
    {
        //清空购买历史记录
        $('#discussBox').empty();
        $('#discussBox').parent().parent().find('.pages_bar').remove();

        for(var item in json.data)
        {
            var historyHtml = template.render('discussRowTemplate',json.data[item]);
            $('#discussBox').append(historyHtml);
        }
        $('#discussBox').parent().after(json.pageHtml);
    });
}

//发布讨论数据
function sendDiscussData()
{
    var content = $('#discussContent').val();
    var captcha = $('[name="captcha"]').val();

    if($.trim(content)=='')
    {
        alert('请输入讨论内容!');
        $('#discussContent').focus();
        return false;
    }
    if($.trim(captcha)=='')
    {
        alert('请输入验证码!');
        $('[name="captcha"]').focus();
        return false;
    }

    var url = '{url:/site/discussUpdate/id/$id/captcha/@captcha@/random/@Math@}';
    url = url.replace("@captcha@",captcha).replace("@Math@",Math.random);

    $.getJSON(url,{'content':content},function(json)
    {
        if(json.isError == false)
        {
            var discussHtml = template.render('discussRowTemplate',json);
            $('#discussBox').prepend(discussHtml);

            //清除数据
            $('#discussContent').val('');
            $('[name="captcha"]').val('');
            $('#discussTable').hide('normal');
            changeCaptcha('{url:/site/getCaptcha}');
        }
        else
        {
            alert(json.message);
        }
    });
}

/**
 * 规格的选择
 * @param _self 规格本身
 */
function sele_spec(_self)
{
    var specObj = $.parseJSON($(_self).attr('value'));

    //清除同规格下已选数据
    $('#selectedSpan'+specObj.id).remove();

    //已经为选中状态时
    if($(_self).attr('class') == 'current')
    {
        $(_self).removeClass('current');
        $('#selectedSpan'+specObj.id).remove();
    }
    else
    {
        //清除同行中其余规格选中状态
        $('#specList'+specObj.id).find('a.current').removeClass('current');

        $(_self).addClass('current');
        var newSpecHtml = template.render('selectedSpecTemplate',specObj);
        $('#specSelected').append(newSpecHtml);
    }

    //检查规格是否选择符合标准
    if(checkSpecSelected())
    {
        //整理规格值
        var specArray = [];
        $('[name="specCols"]').each(function(){
            specArray.push($(this).find('a.current').attr('value'));
        });
        var specJSON = '['+specArray.join(",")+']';
/*alert(specJSON)*/
//alert({$id})
        //获取货品数据并进行渲染
        $.getJSON('{url:/site/getProduct}',{"goods_id":"{$id}","specJSON":specJSON,"random":Math.random},function(json){
            if(json.flag == 'success')
            {
                
                //普通商品购买方式(非团购，抢购等),商品价格渲染
                if($('#priceLi').length > 0)
                {
                    var priceHtml = template.render('priceTemplate',json.data);
                    $('#priceLi').replaceWith(priceHtml);
                }
                //非普通商品购买方式，商品价格渲染
                else if($('#data_sellPrice').length > 0)
                {
                    $('#data_sellPrice').text(json.data.sell_price);
                }

                //普通货品数据渲染
                $('#data_goodsNo').text(json.data.products_no);
                $('#data_storeNums').text(json.data.store_nums);
                $('#data_marketPrice').text("￥"+json.data.market_price);
                $('#data_weight').text(json.data.weight);
                $('#product_id').val(json.data.id);

                //库存监测
               // checkStoreNums();
            }
            else
            {
                alert(json.message);
                closeBuy();
            }
        });
    }
}

/**
 * 监测库存操作
 */
function checkStoreNums()
{
    var storeNums = parseInt($.trim($('#data_storeNums').text()));
    if(storeNums > 0)
    {
        openBuy();
    }
    else
    {
        closeBuy();
    }
}

/**
 * 检查规格选择是否符合标准
 * @return boolen
 */
function checkSpecSelected()
{
    if($('[name="specCols"]').length === $('[name="specCols"] .current').length)
    {
        return true;
    }
    return false;
}

//检查购买数量是否合法
function checkBuyNums()
{
    //购买数量小于0
    var buyNums = parseInt($.trim($('#buyNums').val()));
    if(buyNums <= 0)
    {
        $('#buyNums').val(1);
        return;
    }

    //购买数量大于库存
    var storeNums = parseInt($.trim($('#data_storeNums').text()));
    if(buyNums >= storeNums)
    {
        $('#buyNums').val(storeNums);
        return;
    }
}

/**
 * 购物车数量的加减
 * @param code 增加或者减少购买的商品数量
 */
function modified(code)
{
    var buyNums = parseInt($.trim($('#buyNums').val()));
    switch(code)
    {
        case 1:
        {
            buyNums++;
        }
        break;

        case -1:
        {
            buyNums--;
        }
        break;
    }

    $('#buyNums').val(buyNums);
    checkBuyNums();
}



//添加收藏夹
function favorite_add(obj)
{
    {if:isset($this->user['user_id'])}
        $.getJSON('{url:/simple/favorite_add}',{'goods_id':{$id},'random':Math.random},function(content)
        {
            if(content.isError == false)
            {
                $(obj).text(content.message);
            }
            else
            {
                alert(content.message);
            }
        });
    {else:}
        window.location.href="{url:/simple/login/?callback=/site/products/id/$id}";
    {/if}
}

//立即购买按钮
function buy_now()
{
 
    //对规格的检查
    if(!checkSpecSelected())
    {
        tips('请选择商品的规格');
        return;
    }

    //设置必要参数
    var buyNums  = parseInt($.trim($('#buyNums').val()));
    var id = {$id};
    var type = 'goods';

    if($('#product_id').val())
    {
        id = $('#product_id').val();
        type = 'product';
            }

/*    {if:$promo}
    //有促销活动（团购，抢购）
    var url = '{url:/simple/cart2/id/@id@/num/@buyNums@/type/@type@/promo/$promo/active_id/$active_id}';
    url = url.replace('@id@',id).replace('@buyNums@',buyNums).replace('@type@',type);
    {else:}*/
    //普通购买
    var url = '{url:/simple/cart2/id/@id@/num/@buyNums@/type/@type@}';
    url = url.replace('@id@',id).replace('@buyNums@',buyNums).replace('@type@',type);
  /*  {/if}*/

    //页面跳转
    window.location.href = url;
}
</body>
</html>
